$.ajax({
    url: "../../order/all",
    type: "get",
    dataType: "json",
    success: function (data) {
        var content = "";
        for (var i = 0; i < data.length; i++) {
            order = data[i];
            content +='<tr>'
				+'<td>'+order.ordernum+'</td>'
				+'<td>'+(order.payway === undefined ? "" : order.payway)+'</td>'
				+'<td>' +(order.money === undefined ? "" : order.money)+'</td>'
            	+ '<td>'+(order.deposit === undefined ? "" : order.deposit)+'</td>'
            	+ '<td>'+(order.orderdate === undefined ? "" : order.orderdate)+'</td>'
            	+ '<td>'+(order.startdate === undefined ? "" : order.startdate)+'</td>'
            	+ '<td>'+(order.enddate === undefined ? "" : order.enddate)+'</td>'
            	+ '<td>'+(order.day === undefined ? "" : order.day)+'</td>';
            if (order.status === 0) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-blue" onclick="changeStatus('+order.order_id+')">等待付款</a>'
                    + '</td>';
            } else if (order.status === 1) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-red" onclick="changeStatus('+order.order_id+')">已支付</a>'
                    + '</td>';
            } else if (order.status === 2) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-red" onclick="changeStatus('+order.order_id+')">预约成功</a>'
                    + '</td>';
            } else if (order.status === 3) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-cyan" onclick="changeStatus('+order.order_id+')">预约失败</a>'
                    + '</td>';
            } else if (order.status === 4) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-green" onclick="changeStatus('+order.order_id+')">入住成功</a>'
                    + '</td>';
            } else if (order.status === 5) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-blue" onclick="changeStatus('+order.order_id+')">申请取消订单</a>'
                    + '</td>';
            } else if (order.status === 6) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-gray" onclick="changeStatus('+order.order_id+')">已退款</a>'
                    + '</td>';
            } else if (order.status === 7) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-gray" onclick="changeStatus('+order.order_id+')">取消成功</a>'
                    + '</td>';
            } else if (order.status === 8) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-cyan" onclick="changeStatus('+order.order_id+')">订单完成</a>'
                    + '</td>';
            } else if (order.status === 9) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-cyan" onclick="changeStatus('+order.order_id+')">已评论</a>'
                    + '</td>';
            } else if (order.status === 10) {
                content += '<td>'
                    + '<a class="layui-btn layui-btn-sm layui-bg-black" onclick="changeStatus('+order.order_id+')">团队订单</a>'
                    + '</td>';
            }
            content += '<td>'
                + '<a class="layui-btn layui-btn-sm layui-bg-blue" onclick="orderItem(' + order.order_id + ')"><i class="layui-icon">&#xe615;</i>查看</a>'
                + '<a class="layui-btn layui-btn-sm layui-bg-blue" onclick="updateOrder(' + order.order_id + ')"><i class="layui-icon"></i>修改</a>'
                + '</td>'
                + '</tr>';
        }
        $("#orderList").html(content);
    }


});


//修改订单信息
function updateOrder(order_id) {
    layui.use('layer', function () {
        var layer = layui.layer;
        b1s = layer.open({
            title: "修改订单信息",
            type: 2,
            area: ['70%', '70%'],
            scrollbar: true, //默认：true,默认允许浏览器滚动，如果设定scrollbar: false，则屏蔽
            maxmin: true,
            content: 'updateOrder.html',
            success: function (layero, index) {
                var iframe = window['layui-layer-iframe' + index];
                iframe.child(order_id)
            }
        });
    });
}


//查看订单信息
function orderItem(order_id) {
    layui.use('layer', function () {
        //访问后端
        location.href="/order/create?order_id=" + order_id;

    });
}

//改变订单状态
function changeStatus(order_id) {
	layui.use('layer', function() {
		var layer = layui.layer;
		//iframe层-父子操作
		b1s = layer.open({
			title: "修改状态",
			type: 2,
			area: ['60%', '40%'],
			scrollbar: true, //默认：true,默认允许浏览器滚动，如果设定scrollbar: false，则屏蔽
			maxmin: true,
			content: 'orderStatus.html',
			success: function(layero, index) {
				var iframe = window['layui-layer-iframe' + index];
				iframe.child(order_id)
			}
		});
	});
}

